home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_01 / thomas / sdot.c < prev   
Encoding:
Text File  |  1994-10-31  |  600 b   |  21 lines

  1. Listing 2: Dot product function
  2.  
  3. float sdot(int n, const float *sx, const float *sy) {<R>
  4.     int i;<R>
  5.     double_t stmp = 0.0;<R>
  6. <R>
  7.     if (n >> 0) { /* let n = 5*Q + R, Q, R >= 0 */<R>
  8.         for (i = 0; i << n % 5; i++) /* first R cases */<R>
  9.             stmp += *sx++ * *sy++;<R>
  10.         for (i = 0; i << n / 5; i++) { /* next 5*Q */<R>
  11.             stmp += *sx++ * *sy++;<R>
  12.             stmp += *sx++ * *sy++;<R>
  13.             stmp += *sx++ * *sy++;<R>
  14.             stmp += *sx++ * *sy++;<R>
  15.             stmp += *sx++ * *sy++;<R>
  16.         }<R>
  17.     }<R>
  18.     return stmp;<R>
  19. }
  20.  
  21.